<template>
	<el-dialog :before-close="handleClose" title="操作日志" :visible.sync="visible" width="80%">
		<el-table v-loading="loading" :data="tableData" stripe>
			<el-table-column align="center" label="操作人" prop="operator" :formatter="(row) => row.operator || '--'" />
			<el-table-column align="center" label="操作类型" prop="operationType"
				:formatter="(row) => row.operationType || '--'" />
			<el-table-column align="center" label="变更前状态" prop="beforeStatus"
				:formatter="(row) => row.beforeStatus || '--'" />
			<el-table-column align="center" label="变更后状态" prop="afterStatus" :formatter="(row) => row.afterStatus || '--'" />
			<el-table-column align="center" label="操作时间" prop="operationAt" :formatter="(row) => row.operationAt || '--'" />
			<el-table-column align="center" label="操作内容" prop="content" :formatter="(row) => row.content || '--'" />
		</el-table>
		<pagination :limit.sync="query.pageSize" :page.sync="query.pageNum" :total="total" @pagination="getList" />
	</el-dialog>
</template>
<script>
import {
	getLog,//日志
} from "@/api/exchangeAndRedemption/index"

export default {
	name: "Log",
	data() {
		return {
			visible: false,
			loading: false,
			total: 0,
			tableData: [],
			entityId: null,
			query: {
				pageNum: 1,
				pageSize: 10,
			},
		};
	},
	methods: {
		// 初始化方法
		init(record) {
			this.visible = true;
			this.entityId = record.id;
			this.getList();
		},
		getList() {
			this.loading = true;
			let query = {
				...this.query,
				entityId: this.entityId,
			};
			getLog(query)
				.then((res) => {
					this.tableData = res.rows;
					this.total = +res.total;
				})
				.finally(() => {
					this.loading = false;
				});
		},
		handleClose() {
			this.visible = false;
			this.dwnLoading = false;
		},
	},
};
</script>
